#include<iostream>
using namespace std;
typedef long long LL;
LL b;
LL fun(LL a, LL b)
{
	LL ans = 1;
	while (b) {
		if (b & 1)ans = ans * a;
		a = a * a;
		b >>= 1;
	}
	return ans;
}
int main()
{
	cin >> b;
	LL ans = 1;
	LL k = fun(ans, ans);
	while (k <= b) {
		if (k == b) {
			cout << ans << endl;
			return 0;
		}
		ans++;
		k = fun(ans, ans);
	}
	cout << "-1" << endl;
	return 0;
}